<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<jsp:useBean id="overtime" class="com.kamikaze.Overtime" scope="session" />

<%--用javabean取得現在時間再用jstl標籤轉為可用之格式 --%>
<jsp:useBean id="now" class="java.util.Date" scope="session" />
<fmt:formatDate var="today" value="${now }" pattern="yyyy-MM-dd"/>
<%--用javabean取得現在時間再用jstl標籤轉為可用之格式 --%>

<table align="center">
<caption><h1>加班申請</h1></caption>
<hr>
<form action="overtime" method="post">
	<tr><td>員工編號：</td><td>${member.user_id}</td></tr>
	<input type="hidden" name="user_id" value="${ member.user_id}">
	<tr><td>加班日期(起)：</td><td><input type="text" name="date_begin" value="${today }" class="datepicker" /></td></tr>
	<tr><td>加班日期(訖)：</td><td><input type="text" name="otd_date" value="${today }" class="datepicker" /></td></tr>
	<tr><td>加班時間(起)：</td><td><input type="text" name="otd_time_begin" id="time3" value="08:00"/></td></tr>
	<tr><td>加班時間(訖)：</td><td><input type="text" name="otd_time_end" id="time4" value="09:00"/></td></tr>
	<tr><td>加班別：</td><td>
	<select name="ot_number" value="1" />
		<option value="1">補休
		<option value="2">付薪
	</select></td></tr>
	<tr><td>核可主管：</td><td>0001</td></tr>
	<input type="hidden" name="checker_id" value="0001" />
	<tr><td>事由：</td><td><textarea type="text" name="otd_note" value=""></textarea></td></tr>
	<tr><td></td><td><input type="submit" value="送出加班單"/></td></tr>
</form>
</table>
<%
for (String msg : overtime.getErrors()) {
	%><h2><%=msg %></h2><%
}
%>
<br><br>
<sql:query var="rs" dataSource="jdbc/j2db" >
	SELECT od.otd_number, s.shift_number, us.user_id, us.user_name, 
	od.otd_date, od.otd_time_begin, od.otd_time_end, od.approved, od.checker_id, 
	od.otd_note, ot.ot_name,otd_time
	FROM shift s, overtimedata od, users us, overtimes ot
	WHERE s.user_id = us.user_id
	AND s.shift_number = od.shift_number
	AND od.ot_number = ot.ot_number
	AND us.user_id = ?
	<sql:param>${member.user_id}</sql:param>
</sql:query>

已提出之加班申請：
<table border=1 align="center">
	<tr>
		<th>加班編號</th>
		<th>員工編號</th>
		<th>員工姓名</th>
		<th>加班日期</th>
		<th>起始時間</th>
		<th>結束時間</th>
		<th>加班別</th>
		<th>申請時間</th>
		<th>核可</th>
		<th>核可主管</th>
		<th>備註</th>
	</tr>
<c:forEach var="r" items="${rs.rows}">
	<tr>
		<td>${r.otd_number }</td>
		<td>${r.user_id }</td>
		<td>${r.user_name }</td>
		<td>${r.otd_date }</td>
		<td>${r.otd_time_begin }</td>
		<td>${r.otd_time_end }</td>
		<td>${r.ot_name }</td>
		
		<fmt:formatDate var="otd_time" value="${r.otd_time }" pattern="yyyy-MM-dd hh:mm:ss"/>
		<td>${otd_time }</td>
		
		<td>${r.approved }</td>
		<td>${r.checker_id }</td>
		<td>${r.otd_note }</td>
	</tr>
</c:forEach>
</table>